#include <iostream>
#include <deque>
#include <vector>
#include <algorithm>

using namespace std;

/* deque的构造和访问 */
void test1()
{
    int arr[] = {5, 15, 25, 35};
    deque<int> mydeque;
    for(int i = 0; i < 5; i++)
        mydeque.push_back(i);       /* 尾部插入数据元素 */
    mydeque.push_front(10);         /* 头部插入数据元素 */
    mydeque.push_front(20);
    mydeque.insert(mydeque.begin()+3, 100);         /* 中间位置插入元素 */
    mydeque.insert(mydeque.begin()+4, arr, arr+4);

    for (int i = 0; i < mydeque.size()+1; i++) {
        try{
            cout << mydeque[i] << " ";
        } catch (exception &e) {
            cout << endl;
            cout << e.what() << endl;
            break;
        }
    }
    cout << endl;

    deque<int> mydeque1(mydeque.begin()+2, mydeque.end()-3);
    deque<int> mydeque2(5,10);

    mydeque2.swap(mydeque1);
    for (int i = 0; i < mydeque1.size()+1; i++) {
        try{
            cout << mydeque1.at(i) << " ";
        } catch (exception &e) {
            cout << endl;
            cout << e.what() << endl;
            break;
        }
    }

    for (deque<int>::iterator it = mydeque2.begin(); it != mydeque2.end(); it++)
        cout << *it << " ";
    cout << endl;

}


class Demo {
public:
    Demo(string myname) {
        name = myname;
    }
public:
    string name;
    deque<int> dq;
};

void test2()
{
    vector<Demo> v;

    /* 创建用户 */
    for (int i = 0; i < 5; i++) {
        string myname;
        cin >> myname;
        Demo obj(myname);
        v.push_back(obj);
    }

    /* 打分 */
    for (int i = 0; i < v.size(); i++) {
        for (int j = 0; j < 10; j++) {
            srand((i+1) * (j+1));
            int num = rand() % 11;
            v[i].dq.push_back(num);
            //v[i].push_back(num);
        }
    }

    /* 计算获取最后结果 */
    for (int i = 0; i < v.size(); i++) {
        sort(v[i].dq.begin(), v[i].dq.end(), less<int>());        /* 升序排序 */
        /* 去掉最高分和最低分 */
        v[i].dq.pop_back();
        v[i].dq.pop_front();
        /* 计算总分 */
        int score = 0;
        for (int j = 0; j < v[i].dq.size(); j++) {
            score += v[i].dq.at(j);
        }
        /* 计算平均分，并输出 */
        cout << v[i].name << " : " << (float)score/v[i].dq.size() << endl;
    }
}


int main()
{
    test2();
    return 0;
}
